// 定义一个模块， 并导出

import { ApiRes,  GoodsInfo } from "@/types/data";
import request from "@/utils/request";
import { defineStore } from "pinia";

export default defineStore('goods', {
  state: () => ({
    info: {} as GoodsInfo
  }),
  actions: {
    // 拿商品详情数据
    async getGoodsInfo (id: string) {
      const res = await request.get<ApiRes<GoodsInfo>>('/goods', {
        params: {
          id
        }
      })
      console.log('getGoodsInfo', res);
      
      this.info = res.data.result
    }
  }
})